<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dsygst.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="DSYGST.1"></a><a href="dsygst.f.html#DSYGST.1">DSYGST</a>( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          UPLO
      INTEGER            INFO, ITYPE, LDA, LDB, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      DOUBLE PRECISION   A( LDA, * ), B( LDB, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="DSYGST.18"></a><a href="dsygst.f.html#DSYGST.1">DSYGST</a> reduces a real symmetric-definite generalized eigenproblem
</span><span class="comment">*</span><span class="comment">  to standard form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If ITYPE = 1, the problem is A*x = lambda*B*x,
</span><span class="comment">*</span><span class="comment">  and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or
</span><span class="comment">*</span><span class="comment">  B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B must have been previously factorized as U**T*U or L*L**T by <a name="DPOTRF.27"></a><a href="dpotrf.f.html#DPOTRF.1">DPOTRF</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ITYPE   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
</span><span class="comment">*</span><span class="comment">          = 2 or 3: compute U*A*U**T or L**T*A*L.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'U':  Upper triangle of A is stored and B is factored as
</span><span class="comment">*</span><span class="comment">                  U**T*U;
</span><span class="comment">*</span><span class="comment">          = 'L':  Lower triangle of A is stored and B is factored as
</span><span class="comment">*</span><span class="comment">                  L*L**T.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrices A and B.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment">          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
</span><span class="comment">*</span><span class="comment">          N-by-N upper triangular part of A contains the upper
</span><span class="comment">*</span><span class="comment">          triangular part of the matrix A, and the strictly lower
</span><span class="comment">*</span><span class="comment">          triangular part of A is not referenced.  If UPLO = 'L', the
</span><span class="comment">*</span><span class="comment">          leading N-by-N lower triangular part of A contains the lower
</span><span class="comment">*</span><span class="comment">          triangular part of the matrix A, and the strictly upper
</span><span class="comment">*</span><span class="comment">          triangular part of A is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, the transformed matrix, stored in the
</span><span class="comment">*</span><span class="comment">          same format as A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A.  LDA &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (input) DOUBLE PRECISION array, dimension (LDB,N)
</span><span class="comment">*</span><span class="comment">          The triangular factor from the Cholesky factorization of B,
</span><span class="comment">*</span><span class="comment">          as returned by <a name="DPOTRF.62"></a><a href="dpotrf.f.html#DPOTRF.1">DPOTRF</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array B.  LDB &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      DOUBLE PRECISION   ONE, HALF
      PARAMETER          ( ONE = 1.0D0, HALF = 0.5D0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            UPPER
      INTEGER            K, KB, NB
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="DSYGS2.82"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>, DSYMM, DSYR2K, DTRMM, DTRSM, <a name="XERBLA.82"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, MIN
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.88"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      INTEGER            <a name="ILAENV.89"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      EXTERNAL           <a name="LSAME.90"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="ILAENV.90"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      UPPER = <a name="LSAME.97"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
      IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
         INFO = -1
      ELSE IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.100"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -3
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -5
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -7
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.110"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="DSYGST.110"></a><a href="dsygst.f.html#DSYGST.1">DSYGST</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Determine the block size for this environment.
</span><span class="comment">*</span><span class="comment">
</span>      NB = <a name="ILAENV.121"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="DSYGST.121"></a><a href="dsygst.f.html#DSYGST.1">DSYGST</a>'</span>, UPLO, N, -1, -1, -1 )
<span class="comment">*</span><span class="comment">
</span>      IF( NB.LE.1 .OR. NB.GE.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Use unblocked code
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="DSYGS2.127"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Use blocked code
</span><span class="comment">*</span><span class="comment">
</span>         IF( ITYPE.EQ.1 ) THEN
            IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute inv(U')*A*inv(U)
</span><span class="comment">*</span><span class="comment">
</span>               DO 10 K = 1, N, NB
                  KB = MIN( N-K+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Update the upper triangle of A(k:n,k:n)
</span><span class="comment">*</span><span class="comment">
</span>                  CALL <a name="DSYGS2.142"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>( ITYPE, UPLO, KB, A( K, K ), LDA,
     $                         B( K, K ), LDB, INFO )
                  IF( K+KB.LE.N ) THEN
                     CALL DTRSM( <span class="string">'Left'</span>, UPLO, <span class="string">'Transpose'</span>, <span class="string">'Non-unit'</span>,
     $                           KB, N-K-KB+1, ONE, B( K, K ), LDB,
     $                           A( K, K+KB ), LDA )
                     CALL DSYMM( <span class="string">'Left'</span>, UPLO, KB, N-K-KB+1, -HALF,
     $                           A( K, K ), LDA, B( K, K+KB ), LDB, ONE,
     $                           A( K, K+KB ), LDA )
                     CALL DSYR2K( UPLO, <span class="string">'Transpose'</span>, N-K-KB+1, KB, -ONE,
     $                            A( K, K+KB ), LDA, B( K, K+KB ), LDB,
     $                            ONE, A( K+KB, K+KB ), LDA )
                     CALL DSYMM( <span class="string">'Left'</span>, UPLO, KB, N-K-KB+1, -HALF,
     $                           A( K, K ), LDA, B( K, K+KB ), LDB, ONE,
     $                           A( K, K+KB ), LDA )
                     CALL DTRSM( <span class="string">'Right'</span>, UPLO, <span class="string">'No transpose'</span>,
     $                           <span class="string">'Non-unit'</span>, KB, N-K-KB+1, ONE,
     $                           B( K+KB, K+KB ), LDB, A( K, K+KB ),
     $                           LDA )
                  END IF
   10          CONTINUE
            ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute inv(L)*A*inv(L')
</span><span class="comment">*</span><span class="comment">
</span>               DO 20 K = 1, N, NB
                  KB = MIN( N-K+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Update the lower triangle of A(k:n,k:n)
</span><span class="comment">*</span><span class="comment">
</span>                  CALL <a name="DSYGS2.172"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>( ITYPE, UPLO, KB, A( K, K ), LDA,
     $                         B( K, K ), LDB, INFO )
                  IF( K+KB.LE.N ) THEN
                     CALL DTRSM( <span class="string">'Right'</span>, UPLO, <span class="string">'Transpose'</span>, <span class="string">'Non-unit'</span>,
     $                           N-K-KB+1, KB, ONE, B( K, K ), LDB,
     $                           A( K+KB, K ), LDA )
                     CALL DSYMM( <span class="string">'Right'</span>, UPLO, N-K-KB+1, KB, -HALF,
     $                           A( K, K ), LDA, B( K+KB, K ), LDB, ONE,
     $                           A( K+KB, K ), LDA )
                     CALL DSYR2K( UPLO, <span class="string">'No transpose'</span>, N-K-KB+1, KB,
     $                            -ONE, A( K+KB, K ), LDA, B( K+KB, K ),
     $                            LDB, ONE, A( K+KB, K+KB ), LDA )
                     CALL DSYMM( <span class="string">'Right'</span>, UPLO, N-K-KB+1, KB, -HALF,
     $                           A( K, K ), LDA, B( K+KB, K ), LDB, ONE,
     $                           A( K+KB, K ), LDA )
                     CALL DTRSM( <span class="string">'Left'</span>, UPLO, <span class="string">'No transpose'</span>,
     $                           <span class="string">'Non-unit'</span>, N-K-KB+1, KB, ONE,
     $                           B( K+KB, K+KB ), LDB, A( K+KB, K ),
     $                           LDA )
                  END IF
   20          CONTINUE
            END IF
         ELSE
            IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute U*A*U'
</span><span class="comment">*</span><span class="comment">
</span>               DO 30 K = 1, N, NB
                  KB = MIN( N-K+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Update the upper triangle of A(1:k+kb-1,1:k+kb-1)
</span><span class="comment">*</span><span class="comment">
</span>                  CALL DTRMM( <span class="string">'Left'</span>, UPLO, <span class="string">'No transpose'</span>, <span class="string">'Non-unit'</span>,
     $                        K-1, KB, ONE, B, LDB, A( 1, K ), LDA )
                  CALL DSYMM( <span class="string">'Right'</span>, UPLO, K-1, KB, HALF, A( K, K ),
     $                        LDA, B( 1, K ), LDB, ONE, A( 1, K ), LDA )
                  CALL DSYR2K( UPLO, <span class="string">'No transpose'</span>, K-1, KB, ONE,
     $                         A( 1, K ), LDA, B( 1, K ), LDB, ONE, A,
     $                         LDA )
                  CALL DSYMM( <span class="string">'Right'</span>, UPLO, K-1, KB, HALF, A( K, K ),
     $                        LDA, B( 1, K ), LDB, ONE, A( 1, K ), LDA )
                  CALL DTRMM( <span class="string">'Right'</span>, UPLO, <span class="string">'Transpose'</span>, <span class="string">'Non-unit'</span>,
     $                        K-1, KB, ONE, B( K, K ), LDB, A( 1, K ),
     $                        LDA )
                  CALL <a name="DSYGS2.216"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>( ITYPE, UPLO, KB, A( K, K ), LDA,
     $                         B( K, K ), LDB, INFO )
   30          CONTINUE
            ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute L'*A*L
</span><span class="comment">*</span><span class="comment">
</span>               DO 40 K = 1, N, NB
                  KB = MIN( N-K+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Update the lower triangle of A(1:k+kb-1,1:k+kb-1)
</span><span class="comment">*</span><span class="comment">
</span>                  CALL DTRMM( <span class="string">'Right'</span>, UPLO, <span class="string">'No transpose'</span>, <span class="string">'Non-unit'</span>,
     $                        KB, K-1, ONE, B, LDB, A( K, 1 ), LDA )
                  CALL DSYMM( <span class="string">'Left'</span>, UPLO, KB, K-1, HALF, A( K, K ),
     $                        LDA, B( K, 1 ), LDB, ONE, A( K, 1 ), LDA )
                  CALL DSYR2K( UPLO, <span class="string">'Transpose'</span>, K-1, KB, ONE,
     $                         A( K, 1 ), LDA, B( K, 1 ), LDB, ONE, A,
     $                         LDA )
                  CALL DSYMM( <span class="string">'Left'</span>, UPLO, KB, K-1, HALF, A( K, K ),
     $                        LDA, B( K, 1 ), LDB, ONE, A( K, 1 ), LDA )
                  CALL DTRMM( <span class="string">'Left'</span>, UPLO, <span class="string">'Transpose'</span>, <span class="string">'Non-unit'</span>, KB,
     $                        K-1, ONE, B( K, K ), LDB, A( K, 1 ), LDA )
                  CALL <a name="DSYGS2.239"></a><a href="dsygs2.f.html#DSYGS2.1">DSYGS2</a>( ITYPE, UPLO, KB, A( K, K ), LDA,
     $                         B( K, K ), LDB, INFO )
   40          CONTINUE
            END IF
         END IF
      END IF
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DSYGST.247"></a><a href="dsygst.f.html#DSYGST.1">DSYGST</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
